package javafx.com;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

/**
 * @Classname main
 * @Date 2021/09/20 11:07
 * @Author by yx
 * @Description :
 */
public class main extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        Button button1 = new Button("button1");
        Button button2 = new Button("button2");
        Button button3 = new Button("button3");
        Button button4 = new Button("button4");
        Button button5 = new Button("button5");
        Button button6 = new Button("button6");
        Button button7 = new Button("button7");
        Button button8 = new Button("button8");

        // 当宽度小于组件总宽度时,会自动将组件下移
        FlowPane flowPane = new FlowPane();

        flowPane.setStyle("-fx-background-color: #EE6AA7");

        // 组件边距
        flowPane.setPadding(new Insets(10));
        flowPane.setAlignment(Pos.CENTER);
        // 水平间距
        flowPane.setHgap(10);
        // 垂直间距
        flowPane.setVgap(10);
//         设置默认展示方向-垂直
        flowPane.setOrientation(Orientation.VERTICAL);

        flowPane.getChildren().addAll(button1, button2, button3, button4, button5, button6, button7, button8);

        Scene scene = new Scene(flowPane);
        primaryStage.setScene(scene);
        primaryStage.setWidth(800);
        primaryStage.setHeight(800);
        primaryStage.setTitle("javafx");
        primaryStage.show();

    }
}
